package com.kaigejava.webmaginc;


import us.codecraft.webmagic.Page;
import us.codecraft.webmagic.Site;
import us.codecraft.webmagic.Spider;
import us.codecraft.webmagic.processor.PageProcessor;

/**
 * 简单demo1
 * @author kaigejava
 */
public class SimpleDemo4 implements PageProcessor {

    public void process(Page page) {
        //https://blog.csdn.net/weixin_44477805/article/details/104573634
        page.getHtml().links().all();
        page.getHtml().links().all();
        ////*[@id="feedlist_id"]/li[2]/div/div[1]/h2/a
        System.out.println(page.getHtml().xpath("//*[@id=\"feedlist_id\"]/li[2]/div/div[1]/h2/a").toString());
    }

    public Site getSite() {
        return Site.me().setSleepTime(100).setRetryTimes(3);
    }

    public static void main(String[] args) {
        Spider.create(new SimpleDemo4()).addUrl("https://blog.csdn.net").run();
    }
}
